puroresusystemfandomcom-20200214-history
Global Lua Modules/DynamicWelcome
DynamicWelcome is a module that extends the capability of Fandom's welcome tool. This allows for customized messages per administrator, per namespace (corresponding to an editor's first edit), and controlling the probability of which user will act as the greeter (see Selecting a greeter). Install This module should be installed locally in a page titled Module:DynamicWelcome. Configuration modules will be accessed as subpages of this page and may not (as of yet) be configured for an alternate title. The content of the page should comprise of: return require "Dev:DynamicWelcome" Configuration At this moment in time, there are not any default messages included. This module should be configured for the default before initial usage. To configure custom messages, create a Module:DynamicWelcome/msg page. This page may be modified by creating literal nested tables, or using the setup function of this module. The content of the messages may be configured just the same as the default welcome tool (documentation here), but also allows the use of the pipe trick on message rendering (i.e. $1). Config by setup tool This is the suggested method for creating messages, as it is arguably more readable. To configure using the setup tool: 1. Import the setup function through local setup = require("Module:DynamicWelcome").setup 2. Define a message header, in this format: --- AdminName ------- ADMIN = "AdminName" -- or "Wikia" (for admins w/o defined messages) MODE = "message-wall" -- or "message" (for wikis with user talk pages) CHANCE = 1 -- (optional) any int >= 0, indicates relative probability 3. Define whether the following messages are for users or anons. ANON = false -- or true 4. Create a DEFAULT message. DEFAULT = [=[ Message goes here. ]=] 5. Create messages for other namespaces (if desired). Template = [=edited a template! [[Category:Suspicious first edit]]=] Template_talk = [=edited a template talk page.=] 6. Generate message data with the setup function. setup("AdminName", "message-wall", _G) 7. Go back to step 3 to create messages for anons (for the current admin), or go back to step 2 to create messages for other admins. 8. Prepend a return (with a space) onto the last setup statement in the page. return setup( -- things go here ) ;Example (expand to view) local setup = require("Module:DynamicWelcome").setup -- --- Default ------- ADMIN = "Wikia" -- admins without defined messages default here MODE = "message-wall" ANON = false DEFAULT = [=[ Hello $4, Welcome to the wiki! Thanks for your edit to $1. You may contact me here. Thanks! ]=] setup("Wikia", "message-wall", _G) ANON = true DEFAULT = "Hey, sign up." setup("Wikia", "message-wall", _G) --- Admin1 ------- ADMIN = "Admin1" MODE = "message-wall" ANON = false DEFAULT = "yo." Talk = "Hmm, did you say something?" Template = "You modified the template $1." return setup("Admin1", "message-wall", _G) Config by literals This section is a work in progress. ;Example (expand to view) return { 0 = { {"The JoTS", 1} }, "message-wall" = { "user" = { JoTS" = { "DEFAULT" = [=[ This is the default message for undefined namespaces/main namespace. ]=], "Template" = [=[ This is a message for edits to the template namespace. ]=] } } } } Usage For basic implementation, place the following in your wiki's local MediaWiki:Welcome-message-wall-user (or MediaWiki:Welcome-message-user, if using user talk pages): ;For message walls : ;For user talk pages : And place the following in MediaWiki:Welcome-message-wall-anon (or MediaWiki:Welcome-message-anon, if using user talk pages) for anonymous editors: ;For message walls : ;For user talk pages : Selecting a greeter This script is also able to select a user to act as a greeter, with associated probability weight. This functionality may be used with or without utilizing this script's primary functionality (the /msg page would still need to be partially configured however). To enable this feature, place the following in your wiki's local MediaWiki:Welcome-user page: : Internal wikilink to external link This script is also able to convert internal wikilinks (w/o brackets) to external links that target internal pages. This functionality is provided as to minimize welcome messages' impact on wiki's maintenance reports, such as (especially on wikis that are prone to frequent page deletions or page moves). This function is particularly useful (as opposed to utilizing the URL data magic words) for the $1 argument, which may return a result such as Thread:101|I have many questions. This function may be used within the module's associated /msg page, or independently without utilizing the primary functionality of this script. The function may be invoked through the following syntax: :